<?php 
	include('template/header.php');
	include('classess/user_subscribe.php');
	include('classess/enquiry_class.php');
	$new_enq = new New_Enquiry();

	if(isset($_POST['enquiry_user_name'])){
		if(trim($_POST['enquiry_user_name']) != ''){
			$save_enq = $new_enq->saveEnquiryQuery();
		}	
	}
?>
	<section  class="homepage-slider" id="home-slider">
		<div class="flexslider">
			<ul class="slides">
				<li>
					<img src="img/slider/first_image.jpg" alt="No Image" />					
				</li>
				<li>
					<img src="img/slider/second_image.jpg" alt="No Image" />					
				</li>
			</ul>
		</div>			
	</section>		
	<section class="main-content">
		<div class="row">
			
			<div class="span9">													
				<div class="row">
					<div class="span9">
						
						<h4 class="title">
							<span class="pull-left"><span class="text"><span class="line"><strong>Enquiry</strong></span></span></span>
							<span class="pull-right">
								&nbsp;
							</span>
						</h4>						
						<div id="myCarousel" class="myCarousel carousel slide">
							<div class="carousel-inner">
								<div class="active item" style="border:1px solid #CCCCCC;">
									
									<div class="span5" style="border-right:1px solid #CCCCCC; float:left; margin-left:0px; padding-left: 10px;">										
										<?php 
											if(isset($save_enq)){
												if($save_enq != ''){
										?>
										<div class="alert alert-error" style="margin-top:10px;margin-bottom:10px;width:87%;">
											<div style="float: right; width: 5%;"><button type="button" class="close" data-dismiss="alert">&times;</button></div>
											<div style="float:left;width: 92%;word-wrap: break-word;"><?php echo 'Thanks For Enquiry.'; ?></div>
											<div style="clear:both;"></div>							
										</div>
										<?php
												}
											}
										?>
										<div id="respond">
											<form method="POST" name="enquiry_form" id="enquiry_form" action="<?php echo $_SERVER['PHP_SELF']; ?>?en_ac=1">
												<p>
													<input name="enquiry_user_name" type="text" id="enquiry_user_name" size="22" style="width:170px;">
													<span id="ctl00_ContentPlaceHolder1_lblname">Name (required)</span>
												</p>
												<p>
													<input name="enquiry_user_email" type="text" id="enquiry_user_email" size="22" style="width:170px;">
													<span id="ctl00_ContentPlaceHolder1_lblEmail">Email (required)</span>
												</p>
												<p>
													<input name="enquiry_user_contact" type="text" id="enquiry_user_contact" size="22" style="width:170px;">
													<span id="ctl00_ContentPlaceHolder1_Label1">contact (required)</span>
												</p>
												<p>
													<span id="ctl00_ContentPlaceHolder1_lblcomment">Your Query(required)</span><br>
													<textarea name="enquiry_user_query" rows="2" cols="20" id="enquiry_user_query" style="height:200px;width:90%;resize:none;"></textarea>

												</p>
												<p>
													<input name="enquiry_user_submit" type="button" id="enquiry_user_submit" value="Submit">
													&nbsp;
													<!--<input onclick="__doPostBack('ctl00$ContentPlaceHolder1$reset','')" name="ctl00$ContentPlaceHolder1$reset" type="button" id="ctl00_ContentPlaceHolder1_reset" value="Reset">-->
												</p><br>
												<span id="ctl00_ContentPlaceHolder1_lblError" style="color:Red;"></span>
											</form>
										</div>

									</div>
									<div class="span4" style="float:left; margin-left:0px; padding-left:10px; padding-top:10px;">
										<div id="fb-root"></div>
										<script type="text/javascript">
											 (function (d, s, id) {
												 var js, fjs = d.getElementsByTagName(s)[0];
												 if (d.getElementById(id)) return;
												 js = d.createElement(s); js.id = id;
												 js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
												 fjs.parentNode.insertBefore(js, fjs);
											 } (document, 'script', 'facebook-jssdk'));
										</script>
										<div class="fb-like-box" data-href="http://www.facebook.com/rvtrainingsolutions" data-width="330" data-height="350" data-show-faces="true" data-stream="false" data-border-color="black" data-header="true"></div>
									</div>
									<div style="clear:both;"></div>
								</div>
							</div>							
						</div>

					</div>						
				</div>	
			</div>
			<?php include('template/right_panel.php'); ?>
		</div>
	</section>
   
<?php include('template/footer.php'); ?>
<script>
	$ = jQuery.noConflict();
	$(document).ready(function(){	
		$('#enquiry_user_submit').click(function(){
			if($('#enquiry_user_name').val().trim() == ''){			
				alert("Please enter a value for the \"User Name\" field.");
				$('#enquiry_user_name').focus();
				return (false);
			}			
			else if($('#enquiry_user_email').val().trim() == "")
			{
				alert("Please enter a value for the \"Email\" field.");
				$('#enquiry_user_email').focus();				
				return (false);
			}else if(($('#enquiry_user_email').val().indexOf("\@") == -1) || ($('#enquiry_user_email').val().indexOf(".")== -1) || isInvalidateEmail($('#enquiry_user_email').val()))
			{
				alert("Invalid Email Address");
				$('#enquiry_user_email').focus();
				return (false);
			}			
			else if($('#enquiry_user_contact').val().trim() == "")
			{
				alert("Please enter a value for the \"Contact\" field.");
				$('#enquiry_user_contact').focus();				
				return (false);
			}
			else if($('#enquiry_user_query').val().trim() == "")
			{
				alert("Please enter Your Query \"Contact\" field.");
				$('#enquiry_user_query').focus();				
				return (false);
			}else{
				document.enquiry_form.submit();
			}

		});

		$('.close').click(function(){
			$('.alert-error').addClass('hide');
		});
		
	});

	function isInvalidateEmail(str)
	{
		var atpos=str.indexOf("@");
		var dotpos=str.lastIndexOf(".");
		if (atpos<1 || dotpos<atpos+2 || dotpos+2>=str.length)
		  {
		  return true;
		  }
		return false;
	}

</script>